package com.pshcp.patient.tool;

import cn.hutool.core.date.DateUtil;
import com.framework.base.TwoDTO;

import java.util.Date;

public class PatientCommonTools {

    /**
     * 0一周内，1一个月，2半年内，3一年内
     * @param searchTime
     * @return
     */
    public static TwoDTO<String, String> buildStartEndTime(Integer searchTime){
        if(searchTime == 0){
            return new TwoDTO<>(
                    DateUtil.formatDate(DateUtil.offsetDay(new Date(), -7)),
                    DateUtil.today()
            );
        }
        if(searchTime == 1){
            return new TwoDTO<>(
                    DateUtil.formatDate(DateUtil.offsetMonth(new Date(), -1)),
                    DateUtil.today()
            );
        }
        if(searchTime == 2){
            return new TwoDTO<>(
                    DateUtil.formatDate(DateUtil.offsetMonth(new Date(), -6)),
                    DateUtil.today()
            );
        }
        if(searchTime == 3){
            return new TwoDTO<>(
                    DateUtil.formatDate(DateUtil.offsetMonth(new Date(), -12)),
                    DateUtil.today()
            );
        }
        //default week
        return new TwoDTO<>(
                DateUtil.formatDate(DateUtil.offsetDay(new Date(), -7)),
                DateUtil.today()
        );
    }

}
